home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
diskmags
/
3565-4.665
/
dmg-4437
/
packed.12
/
custom4
/
custom4
Wrap
Text File
|
1987-04-21
|
7KB
|
150 lines
Customising Stos
~~~~~~~~~~~~~~~~
Part 4: Ditching The Fileselector
or 'Once more into the breach..' (?)
The fileselector in STOS. Eh? What a nasty bit of code that is. I
personally hate the damn thing, there it sits all smug listing my files
and not letting me do the things I want, like entering *.* as a file
name!! And have you aver noticed that if you have more than 8 drives
connected that the STOS fileselector won't recognise the 9th and over.
Personal opinions aside, the STOS fileselector is a dead give away. If
you need to communicate with the disk through this then everyone knows
what language you've been using. Besides it tends to confuse people
when instead of a nice familiar - if cumbersome - GEM fileselector,
they get STOSs variation on the theme.
Over the next couple of articles were are going to code our own, can
you contain your excitement. I have decided to do it in a cuple of
steps because the article would stupidly long otherwise. In this first
part we're going to get the 'bones' of the selector working.
The routine DISKSCAN.BAS if fully REMmed so you should be able to find
your way around it quite easily, so I'll just cover the not so obvious
points.
The program is basically a subroutine, with a bit added so you can see
whats happening. The actual subroutine starts from line 300. Line 160
(dim F_block$(300)) MUST be set up before you call the subroutine. This
variable array hold the file information block.
STOS automatically generates a 45 character block which contains far
more information than we will normally need, so we'll get rid of the
uneeded parts i.e time,date and type. I will return to this later.
The first section reads in all the files that satisfy the mask setting.
350 N_FILES=0 This is a counter for the number of files that
match our search mask. On return this will hold
the number of items that were found matching
the search mask.
355 FSELERR=0 An error flag. When you return from the routine
you can check this to find out if an error has
occurred. In this instance we are using it to
check for an excess number of files in a
directory. GemDos only allows about 150 or so
files in a directory, but desktop programs like
Neodesk allow any number you want up to 999.
I've set the limit to 300 which is usually
adequte for most circumstances.
360 FSELTMP$=dir first$("*.*",-1)
The search mask "*.*" can be replaced with a variable holding the mask
that you actually require. The -1 represents the type of file that will
be listed. It is best to set it to list all file types and mask out
what we don't need.
390 if left$(FSELTMP$,1)="." then 460
The above line dumps file blocks that have '.' at the beginning.
Because we have used -1 as the type flag STOS will return 'parent' and
'folder identifier' names as '.' and '..' so we have to mask these out.
Keeping them would result in confusion to the user.
420 FSELADD$=" " : if val(right$(FSELTMP$,3))=16 then FSELADD$=chr$(1)
This line needs a bit of explanation. FSELADD$ usually holds a space,
but if the file type is a folder we will want to treat that differently
from normal files. So we identify it with chr$(1). Chr$(1) is used so
that during sort, we can put the folders at the top of the file
listing. chr$(1) comes before everything except a null string which is
chr$(0). You can't use chr$(0) to put the folders at the top because
chr$(0) also means end of string. If we were wanting an unsorted list
- say to see what order AUTO files will run - then we would skip this
sorting section. A simple flag and an if..then statement would suffice.
510 sort F_BLOCK$(300) :this is where the CHR$(1) comes in.
it's less than everything! so it comes first.
550 for FSELT=0 to 300
: F_BLOCK$(FSELT)=mid$(F_BLOCK$(FSELT),2)
: next FSELT
Now that the array has been sorted we strip out the chr$(1) and space
that we put in for sorting purposes.
Line 590- 610 simply got through the list in order to find the first
entry that is not a null string. This is needed because SORT put the
null strings first (which is daft) If we returned from the subroutine
at this point then we would have an array filled with empty strings up
until 300 - N_FILES down!
590 for FSELT=0 to 300
600 if F_BLOCK$(FSELT)<>"" then SFSELT_FILE=FSELT : FSELT=300
610 next FSELT
Now that SFELT_FILE points to the first filled entry we have to move
the information up from this point to start at position zero. This is
again a simple loop.
650 COUNFSELT=0 This is a secondary counter which starts at
zero and will end up equalling N_FILES
660 for FSELT=SFSELT_FILE to 300
Set up a loop to count from SFELT_FILE to the end of the array. All our
file names are below SFSELT_FILE.
670 F_BLOCK$(COUNFSELT)=F_BLOCK$(FSELT) : inc COUNFSELT
Move the the block up to the start+COUNFSELT
680 next FSELT
Thats it. All we have to do now is create a block definition that we
will find useful. In this case we will get rid of the time,date and
type of file it is. Of course because we are getting rid of the file
type marker we will have to replace it with comething. In the GEM
fileselector the folders have a little symbol beside the file name. We
can look at this marker inside the fileselector subroutine to decide
what action is needed. In this case I've used the copyright symbol but
you can create any symbol using the font accessory in STOS.
720 for FSELT=0 to N_FILES
The next line simply adds either a space (for a normal file) or
chr$(189) (for a folder) and cuts off the information we don't need.
730 if val(right$(F_BLOCK$(FSELT),3))=16 then
F_BLOCK$(FSELT)=chr$(189)+left$(F_BLOCK$(FSELT),22)
else F_BLOCK$(FSELT)=" "+left$(F_BLOCK$(FSELT),22)
740 next FSELT
750 return
Well that's it for just now. Next time we will be working on an
interface for the user. In the mean time why don't you have a go at
making an interface. If you make a good one why not send it to Stosser,
other user might find it handy!
Auld Bastid 1993